import Vue from 'vue'
import VueRouter from 'vue-router'
import Advertising from '../components/Advertising.vue'
import RecommendedComments from '@/components/Comments/RecommendedComments.vue'
Vue.use(VueRouter)

const routes = [{
 
    path: "/",
    redirect: '/advertising',
  },
  // 广告页面
  {
    path: '/advertising',
    name: 'advertising',
    component: Advertising,
    meta: {
      playShoww: false
    },
    // 独享路由守卫，判断是否进入引导页
    beforeEnter: (to, from, next) => {
      let token = window.localStorage.getItem('token')
      if (!token) {
        next('/guidePage');
        return
      } else {
        next()
      }
    }
  },
  // 引导页
  {
    path: '/guidePage',
    name: "guidePage",
    meta: {
      playShoww: false
    },
    component: () => import('@/components/GuidePage.vue'),
  },
  // 底部切换栏
  {
    path: '/atTheBottomOfThe',
    name: 'atTheBottomOfThe',
    meta: {
      playShoww: true
    },
    component: () => import('@/views/AtTheBottomOfThe'),
    children: [

      {
        path: "/",
        redirect: '/found',
      },


      // 发现
      {
        path: "/found",
        name: '/found',
        meta: {
          playShoww: true
        },
        component: () => import('@/views/AtTheBottomOfThe/Found')
      },
      // 视频
      {
        path: "/videoview",
        name: '/videoview',
        meta: {
          playShoww: false
        },
        component: () => import('@/views/AtTheBottomOfThe/Videoview')
      },
      // 我的
      {
        path: "/my",
        name: '/my',
        meta: {
          playShoww: false
        },
        component: () => import('@/views/AtTheBottomOfThe/My'),
        beforeEnter: (to, from, next) => {
          let login = window.localStorage.getItem("token");
          // 判断是否登录
          if (!login) {
            next("/login");
            return;
          } else {
            next();
          }
        },
      },
      // 关注
      {
        path: "/focuson",
        name: '/focuson',
        meta: {
          playShoww: true
        },
        component: () => import('@/views/AtTheBottomOfThe/Focuson')
      },
    ]
  },
  // 搜索
  {
    path: '/search',
    name: 'search',
    meta: {
      playShoww: true
    },
    component: () => import('@/views/Search.vue')
  },

  {
    //每日推荐
    path: '/dailyracm',
    name: 'dailyracm',
    meta: {
      playShoww: true
    },
    component: () => import('@/views/DailyRacm.vue')

  },
  //歌单
  {
    path: '/songlist',
    component: () => import('@/views/SongList .vue')
  },
  // 歌单详情页
  {
    path: '/songlistdetails',
    name: 'songlistdetails',
    meta: {
      playShoww: true
    },
    component: () => import('@/views/SongListDetails.vue')
  },
  // 歌单评论页
  {
    path: '/comments',
    name: 'comments',
    component: () => import('@/views/Comments.vue'),
    children: [{
        path: '/',
        redirect: 'recommendedComments',
      },
      // 推荐评论
      {
        path: 'recommendedComments',
        component: RecommendedComments
        // component: () => import('@/components/Comments/RecommendedComments.vue')
      },
      // 最新评论
      {
        path: 'theHottestComments',
        component: () => import('@/components/Comments/TheHottestComments.vue')
      },
      // 最热评论
      {
        path: 'theLatestComments',
        component: () => import('@/components/Comments/TheLatestComments.vue')
      },
    ]
  },
  // 排行榜
  {
    path: '/rankinglist',

    component: () => import('@/views/Rankinglist.vue')
  },
  // 排行榜详情
  {
    path: '/listdetails',
    meta: {
      playShoww: true
    },
    component: () => import('@/views/ListDetails.vue')
  },
  //歌手排行
  {
    path: '/singer',
    component: () => import('@/views/Singer.vue'),
    children: [
      {
        path:'/',
        redirect:'thepopularsinger'
      },
      //歌手详情
      {
      path: 'thepopularsinger',
    
      component: () => import('@/views/ThePopulaRsinger.vue'),
    }]
  },
  // 登录页面
  {
    path: '/login',
    name: 'login',
    meta: {
      playShoww: false
    },
    component: () => import('@/components/Logindom/Login.vue')
  },
  // 歌手详情
  {
    path: "/detailsofTheSinger",
    name: "detailsofTheSinger",
    //   meta: {
    //   playShoww: true
    // },
    component: () => import("@/views/DetailsofTheSinger.vue"),
   
  },
  // 最近播放
  {
    path: "/recentPlay",
    name: "recentPlay",
    meta: {
      playShoww: true
    },
    component: () => import('@/views/RecentPlay.vue')
  }


]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router